package com.zgs.mall.cart.vo;

import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

public class Cart {
    List<CartItem> items;
    private Integer counetNum;//商品数量
    private Integer counetType;//商品类型数量
    private BigDecimal totalAmount;//商品总价
    private BigDecimal reduce=new BigDecimal(0);//优惠价格

    public List<CartItem> getItems() {
        return items;
    }

    public void setItems(List<CartItem> items) {
        this.items = items;
    }

    public Integer getCounetNum() {
        counetNum=0;
        if (items !=null){
            for (CartItem item : items) {
                counetNum+=item.getCount();
            }
        }
        return counetNum;
    }
   public Integer getCounetType() {
        counetType=0;
        if (items !=null){
            for (CartItem item : items) {
                counetType+=1;
            }
        }
        return counetType;
    }


    public BigDecimal getTotalAmount() {
        BigDecimal totalAmount=new BigDecimal("0");
        if (items !=null){
            for (CartItem item : items) {
                if (item.getCheck()){
                    totalAmount=totalAmount.add(item.getTotalPrice());
                }

            }
        }
        return totalAmount;
    }


    public BigDecimal getReduce() {
        return reduce;
    }

    public void setReduce(BigDecimal reduce) {
        this.reduce = reduce;
    }
}
